//
//  WelComeController.swift
//  weibo
//
//  Created by JonsonLiu on 2017/3/1.
//  Copyright © 2017年 JonsonLiu. All rights reserved.
//

import UIKit

class WelComeController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        setupUI()
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        //先更新约束
        headViewImage.snp.updateConstraints { (make) in
            make.top.equalTo(100)
        }
        
        
        
        //开始动画
        UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 0.1, initialSpringVelocity: 0, options: [], animations: {
            
            self.view.layoutIfNeeded()
            
            
        }) { (_) in
            let delegate = UIApplication.shared.delegate as? AppDelegate
            
            delegate?.window?.rootViewController = HTMainViewController()
            
            
        }
    }
    
    func setupUI(){
    
        view.backgroundColor = UIColor.white
        
        view.addSubview(headViewImage)
        view.addSubview(headLable)
        
        headViewImage.snp.makeConstraints { (make) in
            make.size.equalTo(CGSize(width: 90, height: 90))
            make.centerX.equalTo(view)
            make.top.equalTo(200)
        }
        headLable.snp.makeConstraints { (make) in
            make.centerX.equalTo(headViewImage)
            make.top.equalTo(headViewImage.snp.bottom).offset(10)
        }
    }

    private lazy var headViewImage : UIImageView = {
    
        let headViewImage = UIImageView(image: UIImage(named: "tabbar_compose_camera"))
        headViewImage.layer.cornerRadius = 45
        headViewImage.layer.masksToBounds = true
        return headViewImage
        
    }()
    
    private lazy var headLable : UILabel = {
    
        let headLable = UILabel()
        headLable.tintColor = UIColor.black
        headLable.font = UIFont.systemFont(ofSize: 12)
        headLable.text = "欢迎回来"
        return headLable
    }()
}
